import request from '../../utils/Request'
import PageUtils from '../../utils/PageUtils'

export const saveArticle = data => {
  return request({
    method: 'post',
    url: '/api/cms/article/save',
    data: data
  })
}

export const createArticle = (data, idempotentCode) => {
  return request({
    method: 'post',
    url: '/api/cms/article/create',
    data: data,
    headers: {
      common: {
        idempotent: idempotentCode
      }
    }
  })
}

export const updateArticle = data => {
  return request({
    method: 'post',
    url: '/api/cms/article/update',
    data: data
  })
}

export const updateArticleStatus = (articleId, status) => {
  return request({
    method: 'get',
    url: '/api/cms/article/' + articleId + '/status/' + status,
    params: {}
  })
}

export const deleteArticle = bId => {
  return request({
    method: 'get',
    url: '/api/cms/article/delete/' + bId,
    params: {}
  })
}

export const listArticle = (data, current, size) => {
  let pageUrl = PageUtils.page(current, size)
  return request({
    method: 'get',
    url: '/api/cms/article/list?' + pageUrl,
    params: data
  })
}


export const selectArticle = bId => {
  return request({
    method: 'get',
    url: '/api/cms/article/select/' + bId,
    params: {}
  })
}
export const selectArticleDetails = bId => {
  return request({
    method: 'get',
    url: '/api/cms/article/select/details/' + bId,
    params: {}
  })
}